<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商城</title>
<link rel="stylesheet" href="css/home.css" type="text/css" >
</head>
<body>
<!-- 判断用户是否登录 -->
<c:set var="user" scope="session" value="${user}"/>
  <c:choose>
  <c:when test="${empty user}" >
<div class="user">
<div id="welcome">汪  欢迎来到天狗</div>
<div id="dl">
<ul>
<li id="z-dl"><a  href="${pageContext.request.contextPath}/login.do">登录</a></li>
<li id="z-dl"><a  href="${pageContext.request.contextPath}/register.do">免费注册</a></li>
</ul>
</div>
</div>
</c:when>
<c:otherwise>
<div class="user">
<div>汪  </div>
<div id="mhome">
<a href="${pageContext.request.contextPath}/home.do">返回首页</a>
</div>
<form action="${pageContext.request.contextPath }/my.do" id="u-form">
<input type="text" value="${user.account }" id="account">
<input type="submit" value="你好${user.nickname }" id="t-user">
</form>
</div>
</c:otherwise>
</c:choose>
 <div class="sousuo">
 <div>
 <img alt="" src="img/jd.jpg" id="logo">
 </div>
 <div class="f-sousuo">
<form action="${pageContext.request.contextPath}/selectgoods.do" id="f-sousuo">
<input type="text" name="name" id="goods" placeholder="搜索 你想找的商品">
<input type="submit" value="搜索" id="sousuo">
</form>
</div>
</div> 

<c:set var="salary" scope="session" value="${goods}"/>
<c:choose>
<c:when test="${salary.size()>0}" >
<div class="l-goods">
<c:forEach items="${goods }" var="goods">
<div id="l-goods">
<img src="img/${goods.avator }" id="g-img">
<form  action="${pageContext.request.contextPath }/xiangq.do" class="sp-ym">
<input type="text" id="goods_id" name="goods_id" value="${goods.goods_id }">
<input type="submit" id="tijiao">
</form>
<label id="zz" class="zbc">${goods.description}</label>
<label id="money">￥${goods.sum }</label>
<div id="g-bottom">
<label id="g-number">剩余${goods.number }件</label>
<img alt="" src="img/gwck.png" id="gwc">
<form action="${pageContext.request.contextPath }/insertgwc.do">
<input type="text" name="user_id" value="${user.account }" id="gw-none">
  <input type="text" name="goods_id" value="${goods.goods_id }" id="gw-none">
  <input type="text" name="merchant" value="${goods.shop }" id="gw-none">
  <input type="text" name="image" value="${goods.avator }" id="gw-none">
  <input type="text" name="description" value="${goods.description }" id="gw-none">
  <input type="text" name="price" value="${goods.sum }" id="gw-none">
  <input type="text" name="number" value="1" id="gw-none">
   <input type="submit" value="购物车" id="gwcar">
  </form>
</div>
</div>
</c:forEach>
</div>
<div id="f-footer">
已经到底了哦！没有更多商品了！
</div>
</c:when>
<c:otherwise>
<div id="x-xian"></div>
<div id="else">
<img alt="加载失败" src="img/zanwu.jpg" id="wu">
<p id="jieshi">没有找到你搜索的商品！</p>
</div>
</c:otherwise>
</c:choose>
<script type="text/javascript">
var str=document.getElementsByClassName("zbc");
for(var i=0;i<str.length;i++){
	if(str[i].innerHTML.length>=12){
		str[i].innerHTML=str[i].innerHTML.substring(0,12)+"...";
	}else{
		str[i].innerHTMML=str[i].innerHTML;
	}
}
</script>
</body>
</html>